﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace CloverNet.Authorization
{
    public class DefaultStorageProvider : IStorageProvider
    {
        internal static DefaultStorageProvider _instance;

        public static DefaultStorageProvider Current
        {
            get => _instance ?? new DefaultStorageProvider();
            set => _instance = value;
        }

        public virtual object GetValue(string Key)
        {
            return HttpContext.Current.Session[Key];
        }

        public virtual void SetValue(string Key, object Value)
        {
            HttpContext.Current.Session[Key] = Value;
        }

        object IStorageProvider.GetValue(string Key)
        {
            return Current.GetValue(Key);
        }

        void IStorageProvider.SetValue(string Key, object Value)
        {
            Current.SetValue(Key, Value);
        }
    }
}
